﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using mesoBoard.Common;
using mesoBoard.Data;
using mesoBoard.Data.Repositories;

namespace mesoBoard.Services
{
    public class Roles : IRoles
    {
        private IRepositoriesWrapper Repositories;

        public Roles(IRepositoriesWrapper repos)
        {
            this.Repositories = repos;
        }

        public bool UserHasSpecialPermissions(int userID, SpecialPermissions permission)
        {
            User user = Repositories.Users.GetUser(userID);

            IEnumerable<InRole> userInRoles = Repositories.Roles.GetUserInRoles(userID);

            return userInRoles.Any(x => x.Role.SpecialPermissions == (int)permission);
        }
    }
}
